/**
 * Below is a sample adapter for connecting with a webservice.
 */

var myRemoteAdapterUser={
    server:BASE_URL,
    save:function(obj,callback,foo){
        $.get(this.server+"todo.php?axt=save&data="+encodeURIComponent(JSON.stringify(obj)),
            function(id){
                obj.id=id;
                $(document).trigger(obj.name + ":save", obj);
                if(callback)
                    callback(obj);
            }
        );
    },
    fetch:function(item,callback){
        $.get(BASE_URL+"garagesale_items?id="+encodeURIComponent(item.id),
            function(obj){
                
                obj=JSON.parse(obj);
                if(callback)
                    callback(obj);
            }
        );
    },
    fetchAll:function(id,callback){
        $.get(BASE_URL+"garagesales",
            function(obj){
                obj=JSON.parse(obj);
                if(callback)
                    callback(obj);
            }
        );
    },
    remove:function(obj,callback){
        $.get(this.server+"todo.php?axt=delete&data="+encodeURIComponent(obj.id),
            function(obj){
                $(document).trigger(obj.name + ":remove", obj.id);
                obj=JSON.parse(obj);
                if(callback)
                    callback(obj);
            }
        );
    }
}


User =  $.mvc.model.extend("user",{
    validate:function(opts){
        if(opts&&opts.trigger)
            return "error validating";
        return true;
    },
    userID: '',
    userCode: '',
    username: '',
    password: '',
    groupID: '',
    email: '',
    subscription: '',
    subscribed: '',
    plan: '',
    bounced: '',
    dateCreated: '',
    dateModified: '',
    displayName: '',
    firstName: '',
    lastName: '',
    gender: '',
    birthDate: '',
    address1: '',
    address2: '',
    address3: '',
    city: '',
    sub_district: '',
    state: '',
    postcode: '',
    country: '',
    currency: '',
    billingAddress1: '',
    billingAddress2: '',
    billingAddress3: '',
    billingCity: '',
    billingState: '',
    billingPostcode: '',
    billingCountry: '',
    phone: '',
    signature: '',
    bio: '',
    companyName: '',
    companyEmail: '',
    companyWebsite: '',
    companyDescription: '',
    companyLogo: '',
    language: '',
    avatar: '',
    posts: '',
    kudos: '',
    notifications: '',
    privacy: '',
    resetkey: '',
    lastLogin: '',
    custom1: '',
    custom2: '',
    custom3: '',
    custom4: '',
    merchantID: '',
    memberType: '',
    active: '',
    blog: '',
    siteID: '',
    crp: '',
    ewallet_balance: '',
    vip_expired_date: '',
    subscribe_email: '',
    identityNumber: '',
    virtual_account: '',
    bbm: ''
}, myRemoteAdapterUser);

var user = new User();